package report

import (
	"context"
	"sale-admin/internal/dal"
	"sale-admin/internal/dao"
	"sale-admin/internal/models"

	"gorm.io/gorm"
)

type ReportLogService struct{}

func (rl ReportLogService) RobotReportLog(ctx context.Context, db *gorm.DB, merchantID string, Type int,
	StartTime, EndTime string, page, limit int) (
	res []*models.MaRobotReportLog, count int64, err error,
) {
	res, count, err = dao.RobotReportLog{}.List(ctx, dal.Q, merchantID, Type, StartTime, EndTime, page, limit)
	for k, v := range res {
		startTimeBytes, _ := models.DateTime(v.StartTime).MarshalDate()
		res[k].StartTimeFormated = string(startTimeBytes)
		endTimeBytes, _ := models.DateTime(v.EndTime).MarshalDate()
		res[k].EndTimeFormated = string(endTimeBytes)
		addTimebytes, _ := models.DateTime(v.AddTime).MarshalDateTime()
		res[k].AddTimeFormated = string(addTimebytes)
	}
	return
}
